<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Redis Class - Fuel Documentation</title>
	<link href="../assets/css/main.css" media="screen" rel="stylesheet" />
	<script type="text/javascript" src="../assets/js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="../assets/js/nav.js"></script>
	<script type="text/javascript" src="../assets/js/highlight.pack.js"></script>
	<script type="text/javascript">
		$(function() {
			show_nav('classes', '../');
		});
		hljs.tabReplace = '    ';
		hljs.initHighlightingOnLoad();
	</script>
</head>
<body>

	<header>
		<h1>Fuel Documentation</h1>
	</header>

	<div id="main-nav"></div>

	<section id="content">
		<h2>Redis Class</h2>

		<p>The Redis class allows you to interact with a <a href="http://redis.io/">Redis</a> key-value store.</p>

		<article>
			<h4>instance($name = 'default')</h4>
			<p>Create a new named redis instance, or return a named instance if it was created earlier.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$name</kbd></th>
								<td><i><pre class="php"><code>'default'</code></pre></i></td>
								<td>The name of the redis instance requested, as defined the application config db.php file.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>Fuel\Core\Redis Object</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// create the Redis 'mystore' instance
$redis = Redis::instance('mystore');</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

		<article>
			<h4>Redis commands</h4>
			<p>Once you have created a redis object using the instance() method, every valid redis command (see the <a href="http://redis.io/commands">Redis Documenation</a>) as a method of that object.</p>
			<p>Some examples:</p>
			<pre class="php"><code>// create the Redis 'mystore' instance
$redis = Redis::instance('mystore');

// create some test data
$redis->rpush('particles', 'proton');
$redis->rpush('particles', 'electron');
$redis->rpush('particles', 'neutron');

// fetch the range
$particles = $redis->lrange('particles', 0, -1);

// count the number of elements
$particle_count = $redis->llen('particles');

// display the results
echo "&lt;p>The {$particle_count} particles that make up atoms are:&lt;/p>";
echo "&lt;ul>";
foreach ($particles as $particle) {
  echo "&lt;li>{$particle}&lt;/li>";
}
echo "&lt;/ul>";
</code></pre>
		</article>

	</section>

	<section id="footer">
		<p>
			<a href="http://fuelphp.com">Fuel</a> is released under the MIT license.<br />
			&copy; 2010 - 2011 Fuel Development Team
		</p>
	</section>

</body>
</html>
